package com.financing.wap.web.controller.api;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.financing.wap.common.ResultMap;
import com.financing.wap.common.ResultMap.STATUS;
import com.financing.wap.service.IWechatCoreService;
import com.financing.wap.web.controller.BaseController;

/**
 * 微信分享API
 * 
 * @author lisu
 *
 */
@Controller("weixinShareController")
@RequestMapping("/api/wechat")
public class WeixinShareController extends BaseController {

	Logger logger = Logger.getLogger(getClass());

	@Autowired
	private IWechatCoreService wechatCoreServiceImpl;


	/**
	 * 公众平台-JS-SDK  获取wxconfig
	 * 
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	@RequestMapping(value = "/jsapiwxconfig")
	@ResponseBody
	public ResultMap getJSApiwxConfig(HttpServletRequest request,
			HttpServletResponse response) throws IOException {

		logger.info("In apiweixinShare getjsApiwxconfig begin!");
		ResultMap result = new ResultMap();
		try {

			result = wechatCoreServiceImpl.getjsApiwxconfig(request);
			
		} catch (Exception e) {
			result.setStatus(STATUS.ERROR);
			result.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
			logger.error("In apiweixinShare getjsApiwxconfig error!", e);
			
		}
		logger.info("In apiweixinShare getjsApiwxconfig end!");
		return result;

	}
}
